package com.zh.note.huawei.onehundred.身高排序;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @Author: zhanghuan
 * @date: 2023/8/31 10:11
 * @description: create it
 *
 * 100 10
 * 95 96 97 98 99 101 102 103 104 105
 */
public class Main {
    public static void main(String[] args) {
        // Scanner sc = new Scanner(System.in);
        // int height = sc.nextInt();
        // int n = sc.nextInt();
        // sc.nextLine();
        // String s = sc.nextLine();
        int height = 100;
        String s = "95 96 97 98 99 101 102 103 104 105";
        String[] strs = s.split(" ");
        List<Integer> collect = Arrays.stream(strs).map(item -> Integer.parseInt(item)).sorted(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                int differ1 = Math.abs(o1 - height);
                int differ2 = Math.abs(o2 - height);
                return differ1 == differ2 ? o1 - o2 : differ1 - differ2;
            }
        }).collect(Collectors.toList());
        String[] strings = collect.stream().map(Objects::toString).toArray(String[]::new);
        System.out.println(String.join(" ", strings));


    }
}
